package com.ymatou.iapi.m.couponservice.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.m.couponservice.parameter.GetByIdBean;
import com.ymatou.iapi.m.couponservice.parameter.GetConversionBillInfoResp;
import com.ymatou.iapi.m.couponservice.service.GetByIdCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.YmtCouponConversionBill;
import com.ymttest.database.sqlwapper.YmtCouponConversionBillWapper;
/**
*获取兑换码生成状态
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetById{
	private static GetByIdBean getbyidBean;
	private static GetByIdCall getbyidCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取兑换码生成状态");
	}

	@Before
	public void caseUp() {
		getbyidBean=new GetByIdBean();
		getbyidCall=new GetByIdCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getbyidCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetById_001() {
		Logger.start(true,"获取兑换单据详情");
		try {
			YmtCouponConversionBill bill = new YmtCouponConversionBillWapper().getTop1().get(0);
			
			getbyidBean.setConversionBillId(bill.getConversionbillid());
			
			getbyidCall.setData(getbyidBean);
			getbyidCall.callService();	
			
			Logger.verifyEquals("0", getbyidCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getbyidCall.getMessage(), "验证返回Message");

			GetConversionBillInfoResp infoResp = getbyidCall.getConversionBillInfoResp();
			
			Logger.verifyEquals(bill.getConversionbillid(), infoResp.getConversionBillId(), "验证返回conversionBillId");
			Logger.verifyEquals(bill.getGeneratemethod().intValue(), infoResp.getGenerateMethod(), "验证返回generateMethod");
			Logger.verifyEquals(bill.getGeneratequantity(), infoResp.getGenerateQuantity(), "验证返回generateQuantity");
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetById_002() {
		Logger.start(true,"获取兑换单据详情-id穿null");
		try {

			getbyidCall.setData(getbyidBean);
			getbyidCall.callService();	
			
//			Logger.verifyEquals("2", getbyidCall.getCode(), "验证返回code");
			Logger.verifyIsContains("兑换码单据不存在", getbyidCall.getMessage(), "验证返回Message");
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetById_003() {
		Logger.start(true,"获取兑换单据详情-id不存在");
		try {

			getbyidBean.setConversionBillId(99999999);
			getbyidCall.setData(getbyidBean);
			getbyidCall.callService();	
			
//			Logger.verifyEquals("2", getbyidCall.getCode(), "验证返回code");
			Logger.verifyIsContains("兑换码单据不存在", getbyidCall.getMessage(), "验证返回Message");
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}